package ar.com.e2solver.solver;



public class GAResult implements SolverResult {

	private Population finalPopulation;
	private long algorithmDuration;
	private int maxPossibleFitness;
	
	public GAResult(Population finalPopulation, long milisecs){
		this.finalPopulation = finalPopulation;
		this.algorithmDuration = milisecs;
		
		this.maxPossibleFitness = calculateMaxFitness();
	}
	
	private int calculateMaxFitness() {
		int rows = getBestIndividual().getPuzzle().getRowsNumber();
		int cols = getBestIndividual().getPuzzle().getColumnNumbers();
		
		int maxFitness = ((cols - 1) * rows) + ((rows - 1) * cols);
		return maxFitness;
	}

	public Individual getBestIndividual(){
		return this.finalPopulation.getBestIndividual();
	}
	
	public Population getFinalPopulation(){
		return this.finalPopulation;
	}
	
	public float getPopulationES(){
		return this.finalPopulation.getES();
	}
	
	public float getPopulationVS(){
		return this.finalPopulation.getVS();
	}
	
	public long getAlgorithmDuration(){
		return this.algorithmDuration;
	}
	
	public int getMaxPossibleFitness(){
		return this.maxPossibleFitness;
	}
}
